#@layout()

#define main()

<div class="jfa-header-box" id="jfa-header-box">
    <div class="jfa-crumbs" id="jfa-crumbs">
        工艺参数设置
    </div>
    #include("/_view/common/_header_right.html")
</div>
<div class="jfa-content-box" id="jfa-content-box">
    <div class="jfa-content" id="jfa-content">

        <div class="row margin-top-20">
            <div class="form-group col-lg-3">
                <label class="col-sm-4 control-label" >工艺</label>
                <div class="col-sm-8">
                    <input type="text"  id="remark" class="form-control" >
                </div>
            </div>

            <div class="form-group col-lg-2 ">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-primary col-sm-5 " onclick="search()">查询</button>
                    <button type="reset" class="btn btn-default" style="margin-left: 4px;" onclick="reset()">重置</button>
                </div>
            </div>
        </div>
        <table id="history">

        </table>

    </div>
</div>
<script type="text/javascript">
var contentHeight = $("#jfa-content").height();
var datagridHeight=contentHeight;
$('#history').bootstrapTable({
    url: '#(ctx)/admin/logtoc/list',
    method: 'get',
    striped: true,
    cache: false,
    pagination: true,
    sortable: false,
    queryParams: function(params){
    		var data = {
                offset: params.offset,
                remark: $("#remark").val()
            };
            return data;
    },
    sidePagination: "server",
    pageNumber:1,
    toolbarAlign:"right",
    pageSize: 100,
    pageList: [100],
    search: false,
    strictSearch: true,
    showColumns: false,
    showRefresh: false,
   	height: datagridHeight-50,
    uniqueId: "id",
    showToggle:false,
    cardView: false,
    detailView: false,
    columns: [
        {
            field: 'remark',  title: '工艺'
        }, {
            field: 'unit',  title: '单位'
        }, {
            field: 'parameter_min_value',  title: '最小值'
        }, {
            field: 'parameter_max_value',  title: '最大值'
        }, {
            field: 'control_flag',  title: '是否启用',formatter:flagFormatter
        }, {
            title: '操作',formatter:curveFormatter
        }
    ],
    onLoadSuccess:function(){
        initMagicInput(prepareAction);
    }
});


function curveFormatter(value, row, index){
    return "<a href='#(ctx)/admin/logtoc/edit?id="+row.id+"'>"+
        "<i class='fa fa-pencil' title='修改'></i></a>";
}

function flagFormatter(value,row,index) {
    var result="<input data-id='"+row.id+"'";
    if (value==1){
        result+=" checked ";
    }

    result+="type='checkbox' class='mgc-switch mgc-tiny'>";

    return result;
}
function search(){
    $('#history').bootstrapTable("refresh",{silent: true});
}
function reset(){
    $("#remark").val("");
    search();
}

function prepareAction($this, state) {
    return {
        url: state ? "#(ctx)/admin/logtoc/doControl" : "#(ctx)/admin/logtoc/notControl",
        data : {
            id: $this.attr("data-id")
        }
    }
}
</script>
#end
